// 创建链接桩
<template>
  <el-button @click="graphAddPort" type="primary" style="margin: 10px"
    >创建链接桩</el-button
  >
  <div id="container"></div>
</template>

<script lang="ts" setup>
import { ElMessage } from "element-plus";
import { Graph, DataUri, Shape } from "@antv/x6";
import { onMounted, ref } from "vue";

let graph = null;

const graphAddPort = () => {
  ElMessage({
    message: "创建链接桩",
    type: "success",
  });
  graph.addNode({
    x: 60,
    y: 60,
    width: 160,
    height: 80,
    label: "Rect With Ports",
    ports: [{ id: "port1" }, { id: "port2" }, { id: "port3" }],
  });
};

const renderGraph = () => {
  graph = new Graph({
    container: document.getElementById("container"),
    width: 800,
    height: 600,
    panning: true,
    mousewheel: true,
    // 设置画布背景颜色
    background: {
      color: "#F2F7FA",
    },
  });

  //创建流程图数据
  const data = {
  };

  graph.fromJSON(data); // 渲染元素
  graph.centerContent(); // 居中显示
};

onMounted(() => {
  renderGraph();
});
</script>
